/**
 * 
 */
package xmlrpc.server;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Qw4z1
 *
 */
public class StringListSender implements StringSenderInterface {
	private volatile LinkedList<String> commands = new LinkedList<String>();
	private volatile int playerNumber =0;
	public int getPlayerNumber(){
		int returnNumber =playerNumber;
		playerNumber++;
		return returnNumber;
	}
	@Override
	public String getString() {
		return commands.getLast();
	}

	@Override
	public boolean setString(String string) {
		commands.add(string);
		return true;
	}
	/**
	 * Returns a list of unexecuted command strings.
	 * @param nr number of the last executed command.
	 * @return list ArrayList of command strings
	 */
	public List<String> getStringList(int nr){
		List<String> list = new ArrayList<String>();
		for(int i = nr ; i < commands.size() ; i++)
			list.add(commands.get(i +1));
		return list;
	}

}
